<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/pages/template/system_template.xhtml">
	<ui:define name="content">
		<div class="div-content">

			<p:growl id="message" autoUpdate="true" showDetail="true"
				showSummary="true" life="10000" />

			<div align="center" class="header-title-page">
				Gerenciamento de Provas
				<p:separator />
			</div>

			<h:form id="frmRemoteCommand">
				<p:remoteCommand name="onloadTabela"
					actionListener="#{provaManagedBean.carregarTabela}" autoRun="true"
					update=":frmProvaDataTable:provaDataTable" />
			</h:form>

			<h:form id="frmProvaDataTable">
				<p:dataTable id="provaDataTable"
					value="#{provaManagedBean.listaProvas}" var="prova" rows="3"
					rowsPerPageTemplate="3,6,9,12" paginator="true"
					emptyMessage="Não há registros."
					paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

					<p:column headerText="Prova" style="width:22%">
						<h:outputText value="#{prova.titulo}" />
					</p:column>

					<p:column headerText="Questões" style="width:40%">
						<ul style="list-style-type: none;">
							<ui:repeat var="questao" value="#{prova.listaQuestoes}">
								<li><h:outputText value="#{questao.tituloQuestao}" /> <p:commandButton
										id="btnEditQuestao" title="Editar questão"
										icon="ui-icon-wrench" oncomplete="dialogEditQuestao.show()"
										actionListener="#{provaManagedBean.carregarTemas}"
										style="width:20px; height:20px; margin-left:5px;"
										update=":idDialogEditQuestao">
										<f:setPropertyActionListener
											target="#{provaManagedBean.questaoSelecionada}"
											value="#{questao}" />
										<f:setPropertyActionListener
											target="#{provaManagedBean.provaSelecionada}"
											value="#{prova}" />
									</p:commandButton> <p:commandButton icon="ui-icon-trash"
										style="width:20px; height:20px;"
										oncomplete="dialogExcluirQuestao.show()"
										update=":idDialogExcluirQuestao" title="Excluir questão">
										<f:setPropertyActionListener value="#{questao}"
											target="#{provaManagedBean.questaoSelecionada}" />
									</p:commandButton> <p:commandButton icon="ui-icon-plus" title="Adicionar opções"
										style="width:20px; height:20px;"
										action="#{provaManagedBean.carregarOpcoes}"
										update=":idDialogCadOpcoes"
										oncomplete="dialogCadOpcoes.show()">
										<f:setPropertyActionListener value="#{questao}"
											target="#{provaManagedBean.questaoSelecionada}" />
									</p:commandButton> <p:commandButton id="viewQuestao" icon="ui-icon-search"
										title="Visualizar questão" style="width:20px; height:20px;"
										oncomplete="dialogViewQuestao.show()" update=":frmDialogView">
										<f:setPropertyActionListener value="#{questao}"
											target="#{provaManagedBean.questaoSelecionada}" />
									</p:commandButton></li>
							</ui:repeat>
						</ul>
					</p:column>

					<p:column headerText="Apostilas" style="width:25%">
						<ul style="list-style-type: none;">
							<ui:repeat var="apostila" value="#{prova.listaApostilas}">
								<li>#{apostila.nome}<p:commandButton icon="ui-icon-trash"
										style="width:20px; height:20px; margin-left:5px;"
										oncomplete="dialogExcluirApostila.show()"
										update=":idDialogExcluirApostila" title="Excluir apostila">
										<f:setPropertyActionListener value="#{apostila}"
											target="#{provaManagedBean.apostilaSelecionada}" />
									</p:commandButton></li>
							</ui:repeat>
						</ul>
					</p:column>

					<p:column headerText="Ações" styleClass="centralizar"
						style="width:13%;">
						<p:commandButton id="btnEdit" title="Editar Prova"
							icon="ui-icon-wrench" oncomplete="dialogEditProva.show()"
							update=":idDialogEditProva">
							<f:setPropertyActionListener
								target="#{provaManagedBean.provaSelecionada}" value="#{prova}" />
						</p:commandButton>

						<p:commandButton id="btnExc" title="Excluir Prova" disabled="#{prova.quantidadeAgendada gt 0}"
							icon="ui-icon-trash" oncomplete="dialogExcluirProva.show()"
							update=":idDialogExcluirProva">
							<f:setPropertyActionListener
								target="#{provaManagedBean.provaSelecionada}" value="#{prova}" />
						</p:commandButton>

						<p:commandButton id="btnAddQuestao" title="Cadastrar Questao"
							icon="ui-icon-circle-plus" oncomplete="dialogCadQuestao.show()"
							actionListener="#{provaManagedBean.carregarTemas}"
							update=":idDialogCadQuestao">
							<f:setPropertyActionListener
								target="#{provaManagedBean.provaSelecionada}" value="#{prova}" />
						</p:commandButton>

						<p:commandButton id="btnAddApostila" title="Adicionar Apostila"
							icon="ui-icon-document" oncomplete="dialogAddApostila.show()"
							update=":idDialogAddApostila">
							<f:setPropertyActionListener
								target="#{provaManagedBean.provaSelecionada}" value="#{prova}" />
						</p:commandButton>

					</p:column>
				</p:dataTable>

				<p:commandButton value="Adicionar prova" style="margin-top: 10px;"
					actionListener="#{provaManagedBean.carregarTemas}"
					oncomplete="dialogCadProva.show()" update=":idDialogCadProva" />

			</h:form>

			<ui:include src="/pages/system/dialog/dialog_cadastrar_prova.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_editar_prova.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_excluir_prova.xhtml" />


			<ui:include src="/pages/system/dialog/dialog_cadastrar_questao.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_editar_questao.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_excluir_questao.xhtml" />


			<ui:include src="/pages/system/dialog/dialog_cadastrar_opcoes.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_excluir_opcao.xhtml" />


			<ui:include
				src="/pages/system/dialog/dialog_adicionar_apostila.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_excluir_apostila.xhtml" />


			<ui:include src="/pages/system/dialog/dialog_view_questao.xhtml" />

		</div>
	</ui:define>
</ui:composition>

</html>